skip to main content
10.1145/3519939.3523703acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

Semantic soundness for language interoperability

Published:09 June 2022Publication History

ABSTRACT

Programs are rarely implemented in a single language, and thus questions of type soundness should address not only the semantics of a single language, but how it interacts with others. Even between type-safe languages, disparate features can frustrate interoperability, as invariants from one language can easily be violated in the other. In their seminal 2007 paper, Matthews and Findler proposed a multi-language construction that augments the interoperating languages with a pair of boundaries that allow code from one language to be embedded in the other. While this technique has been widely applied, their syntactic source-level interoperability doesn’t reflect practical implementations, where the behavior of interaction is only defined after compilation to a common target, and any safety must be ensured by target invariants or inserted target-level “glue code.”

In this paper, we present a novel framework for the design and verification of sound language interoperability that follows an interoperation-after-compilation strategy. Language designers specify what data can be converted between types of the two languages via a convertibility relation τA ∼ τB (“τA is convertible to τB”) and specify target-level glue code implementing the conversions. Then, by giving a semantic model of source-language types as sets of target-language terms, they can establish not only the meaning of the source types, but also soundness of conversions: i.e., whenever τA ∼ τB, the corresponding pair of conversions (glue code) convert target terms that behave like τA to target terms that behave like τB, and vice versa. With this, they can prove semantic type soundness for the entire system. We illustrate our framework via a series of case studies that demonstrate how our semantic interoperation-after-compilation approach allows us both to account for complex differences in language semantics and make efficiency trade-offs based on particularities of compilers or targets.

References

  1. Amal Ahmed, Andrew W. Appel, Christopher D. Richards, Kedar N. Swadi, Gang Tan, and Daniel C. Wang. 2010. Semantic Foundations for Typed Assembly Languages. ACM Transactions on Programming Languages and Systems, 32, 3 (2010), March, 1–67.Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Amal Ahmed and Matthias Blume. 2011. An equivalence-preserving CPS translation via multi-language semantics. In Proceeding of the 16th ACM SIGPLAN international conference on Functional Programming, ICFP 2011, Tokyo, Japan, September 19-21, 2011, Manuel M. T. Chakravarty, Zhenjiang Hu, and Olivier Danvy (Eds.). ACM, 431–444. https://doi.org/10.1145/2034773.2034830 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Amal Ahmed, Matthew Fluet, and Greg Morrisett. 2007. L3 : A Linear Language with Locations. Fundamenta Informaticae, 77, 4 (2007), June, 397–449.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Amal Jamil Ahmed. 2004. Semantics of Types for Mutable State. Ph.D. Dissertation. Princeton University.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Andrew W. Appel and David A. McAllester. 2001. An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst., 23, 5 (2001), 657–683. https://doi.org/10.1145/504709.504712 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Edd Barrett, Carl Friedrich Bolz, Lukas Diekmann, and Laurence Tratt. 2016. Fine-grained Language Composition: A Case Study. In 30th European Conference on Object-Oriented Programming (ECOOP 2016), Shriram Krishnamurthi and Benjamin S. Lerner (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 56). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 3:1–3:27. isbn:978-3-95977-014-9 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2016.3 Google ScholarGoogle ScholarCross RefCross Ref
  7. David M. Beazley. 1996. SWIG: An Easy to Use Tool for Integrating Scripting Languages with C and C++. In Fourth Annual USENIX Tcl/Tk Workshop 1996, Monterey, California, USA, July 10-13, 1996, Mark Diekhans and Mark Roseman (Eds.). USENIX Association. https://www.usenix.org/legacy/publications/library/proceedings/tcl96/beazley.htmlGoogle ScholarGoogle Scholar
  8. Nick Benton. 2006. Abstracting allocation: The new new thing. In Computer Science Logic (CSL).Google ScholarGoogle Scholar
  9. Nick Benton and Chung-Kil Hur. 2009. Biorthogonality, Step-indexing and Compiler Correctness. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP ’09). ACM, New York, NY, USA. 97–108. isbn:978-1-60558-332-7 https://doi.org/10.1145/1596550.1596567 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Nick Benton, Andrew Kennedy, and Claudio V Russo. 2004. Adventures in interoperability: the sml. net experience. In Proceedings of the 6th ACM SIGPLAN International conference on Principles and Practice of Declarative Programming. 215–226.Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Nick Benton and Nicolas Tabareau. 2009. Compiling functional types to relational specifications for low level imperative code. In Proceedings of TLDI’09: 2009 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, Savannah, GA, USA, January 24, 2009. 3–14.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Nick Benton and Uri Zarfaty. 2007. Formalizing and Verifying Semantic Type Soundness of a Simple Compiler. In Proceedings of the 9th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP ’07). Association for Computing Machinery, New York, NY, USA. 1–12. isbn:9781595937698 https://doi.org/10.1145/1273920.1273922 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Matthias Blume. 2001. No-longer-foreign: Teaching an ML compiler to speak C “natively”. Electronic Notes in Theoretical Computer Science, 59, 1 (2001), 36–52.Google ScholarGoogle ScholarCross RefCross Ref
  14. Samuele Buro, Roy Crole, and Isabella Mastroeni. 2020. Equational logic and categorical semantics for multi-languages. Electronic Notes in Theoretical Computer Science, 352 (2020), 79–103.Google ScholarGoogle ScholarCross RefCross Ref
  15. Samuele Buro and Isabella Mastroeni. 2019. On the Multi-Language Construction.. In ESOP. 293–321.Google ScholarGoogle Scholar
  16. Manuel MT Chakravarty. 1999. C->HASKELL, or Yet Another Interfacing Tool. In Symposium on Implementation and Application of Functional Languages. 131–148.Google ScholarGoogle Scholar
  17. Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Complete Monitors for Behavioral Contracts. In European Symposium on Programming (ESOP).Google ScholarGoogle Scholar
  18. Robert Bruce Findler and Matthias Blume. 2006. Contracts as pairs of projections. In International Symposium on Functional and Logic Programming. 226–241.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of the seventh ACM SIGPLAN international conference on Functional programming. 48–59.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Kathryn E Gray. 2008. Safe cross-language inheritance. In European Conference on Object-Oriented Programming. 52–75.Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Kathryn E Gray, Robert Bruce Findler, and Matthew Flatt. 2005. Fine-grained interoperability through mirrors and contracts. ACM SIGPLAN Notices, 40, 10 (2005), 231–245.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Matthias Grimmer, Chris Seaton, Roland Schatz, Thomas Würthinger, and Hanspeter Mössenböck. 2015. High-performance cross-language interoperability in a multi-language runtime. In Proceedings of the 11th Symposium on Dynamic Languages. 78–90.Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Rich Hickey. 2020. A history of Clojure. Proceedings of the ACM on programming languages, 4, HOPL (2020), 1–46.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Kohei Honda. 1993. Types for dyadic interaction. In International Conference on Concurrency Theory. 509–523.Google ScholarGoogle ScholarCross RefCross Ref
  25. Kohei Honda, Vasco T Vasconcelos, and Makoto Kubo. 1998. Language primitives and type discipline for structured communication-based programming. In European Symposium on Programming. 122–138.Google ScholarGoogle ScholarCross RefCross Ref
  26. Jonas B. Jensen, Nick Benton, and Andrew Kennedy. 2013. High-Level Separation Logic for Low-Level Code. POPL ’13. Association for Computing Machinery, New York, NY, USA. 301–314. isbn:9781450318327 https://doi.org/10.1145/2429069.2429105 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2018. RustBelt: Securing the Foundations of the Rust Programming Language. In ACM Symposium on Principles of Programming Languages (POPL).Google ScholarGoogle Scholar
  28. Andrew Kennedy and Don Syme. 2001. Design and Implementation of Generics for the .NET Common Language Runtime. In Proceedings of the ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation (PLDI ’01). Association for Computing Machinery, New York, NY, USA. 1–12. isbn:1581134142 https://doi.org/10.1145/378795.378797 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Robert Kleffner. 2017. A Foundation for Typed Concatenative Languages. Master’s thesis. Northeastern University.Google ScholarGoogle Scholar
  30. Neelakantan R. Krishnaswami, Pierre Pradic, and Nick Benton. 2015. Integrating Linear and Dependent Types. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15-17, 2015, Sriram K. Rajamani and David Walker (Eds.). ACM, 17–30. https://doi.org/10.1145/2676726.2676969 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Paul Blain Levy. 2001. Call-by-Push-Value. Queen Mary, University of London. London, UK.Google ScholarGoogle Scholar
  32. Phillip Mates, Jamie Perconti, and Amal Ahmed. 2019. Under Control: Compositionally Correct Closure Conversion with Mutable State. In ACM Conference on Principles and Practice of Declarative Programming (PPDP).Google ScholarGoogle Scholar
  33. Jacob Matthews and Robert Bruce Findler. 2007. Operational semantics for multi-language programs. In Proceedings of the 34th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2007, Nice, France, January 17-19, 2007, Martin Hofmann and Matthias Felleisen (Eds.). ACM, 3–10. https://doi.org/10.1145/1190216.1190220 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Robin Milner. 1978. A theory of type polymorphism in programming. J. Comput. Syst. Sci., 17 (1978), 348–375.Google ScholarGoogle ScholarCross RefCross Ref
  35. Robin Milner, Joachim Parrow, and David Walker. 1992. A calculus of mobile processes, i. Information and computation, 100, 1 (1992), 1–40.Google ScholarGoogle Scholar
  36. Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs. In ICFP. Proceedings of the ACM on Programming Languages, 2, 73:1–73:30.Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Max S. New, William J. Bowman, and Amal Ahmed. 2016. Fully abstract compilation via universal embedding. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016, Jacques Garrigue, Gabriele Keller, and Eijiro Sumii (Eds.). ACM, 103–116. https://doi.org/10.1145/2951913.2951941 Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Max S. New, Dustin Jamner, and Amal Ahmed. 2020. Graduality and Parametricity: Together Again for the First Time. Proceedings of the ACM on Programming Languages, 4, POPL, 46:1–46:32.Google ScholarGoogle Scholar
  39. Max S New, Daniel R Licata, and Amal Ahmed. 2019. Gradual type theory. Proceedings of the ACM on Programming Languages, 3, POPL (2019), 15:1–15:31.Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Martin Odersky and Matthias Zenger. 2005. Scalable component abstractions. In Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications. 41–57.Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Peter-Michael Osera, Vilhelm Sjöberg, and Steve Zdancewic. 2012. Dependent interoperability. In Proceedings of the sixth workshop on Programming Languages meets Program Verification, PLPV 2012, Philadelphia, PA, USA, January 24, 2012, Koen Claessen and Nikhil Swamy (Eds.). ACM, 3–14. https://doi.org/10.1145/2103776.2103779 Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Daniel Patterson, Noble Mushtak, Andrew Wagner, and Amal Ahmed. 2022. Semantic Soundness for Language Interoperability (Technical Appendix). March, Available at https://dbp.io/pubs/2022/semint-tr.pdf.Google ScholarGoogle Scholar
  43. Daniel Patterson, Jamie Perconti, Christos Dimoulas, and Amal Ahmed. 2017. FunTAL: reasonably mixing a functional language with assembly. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2017, Barcelona, Spain, June 18-23, 2017, Albert Cohen and Martin T. Vechev (Eds.). ACM, 495–509. https://doi.org/10.1145/3062341.3062347 Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. James T. Perconti and Amal Ahmed. 2014. Verifying an Open Compiler Using Multi-language Semantics. In Programming Languages and Systems - 23rd European Symposium on Programming, ESOP 2014, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2014, Grenoble, France, April 5-13, 2014, Proceedings, Zhong Shao (Ed.) (Lecture Notes in Computer Science, Vol. 8410). Springer, 128–148. https://doi.org/10.1007/978-3-642-54833-8_8 Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Gabriel Scherer, Max S. New, Nick Rioux, and Amal Ahmed. 2018. FabULous Interoperability for ML and a Linear Language. In Foundations of Software Science and Computation Structures - 21st International Conference, FOSSACS 2018, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2018, Thessaloniki, Greece, April 14-20, 2018, Proceedings, Christel Baier and Ugo Dal Lago (Eds.) (Lecture Notes in Computer Science, Vol. 10803). Springer, 146–162. https://doi.org/10.1007/978-3-319-89366-2_8 Google ScholarGoogle ScholarCross RefCross Ref
  46. Zhong Shao and Valery Trifonov. 1998. Type-directed continuation allocation. In International Workshop on Types in Compilation. 116–135.Google ScholarGoogle ScholarCross RefCross Ref
  47. T. Stephen Strickland, Sam Tobin-Hochstadt, Robert Bruce Findler, and Matthew Flatt. 2012. Chaperones and Impersonators: Run-Time Support for Reasonable Interposition. In ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA). Association for Computing Machinery, New York, NY, USA. 943–962. isbn:9781450315616 https://doi.org/10.1145/2384616.2384685 Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Don Syme. 2006. Leveraging. NET meta-programming components from F# integrated queries and interoperable heterogeneous execution. In Proceedings of the 2006 workshop on ML. 43–54.Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Kaku Takeuchi, Kohei Honda, and Makoto Kubo. 1994. An interaction-based language and its typing system. In International Conference on Parallel Architectures and Languages Europe. 398–413.Google ScholarGoogle ScholarCross RefCross Ref
  50. Jesse Tov and Riccardo Pucella. 2010. Stateful Contracts for Affine Types. In Programming Languages and Systems, 19th European Symposium on Programming, ESOP 2010, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2010, Paphos, Cyprus, March 20-28, 2010. Proceedings.Google ScholarGoogle Scholar
  51. Valery Trifonov and Zhong Shao. 1999. Safe and principled language interoperation. In European Symposium on Programming. 128–146.Google ScholarGoogle Scholar
  52. Alexi Turcotte, Ellen Arteca, and Gregor Richards. 2019. Reasoning About Foreign Function Interfaces Without Modelling the Foreign Language. In 33rd European Conference on Object-Oriented Programming (ECOOP 2019), Alastair F. Donaldson (Ed.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 134). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 16:1–16:32. isbn:978-3-95977-111-5 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2019.16 Google ScholarGoogle ScholarCross RefCross Ref
  53. Peng Wang, Santiago Cuellar, and Adam Chlipala. 2014. Compiler Verification Meets Cross-Language Linking via Data Abstraction. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’14). Association for Computing Machinery, New York, NY, USA. 675–690. isbn:9781450325851 https://doi.org/10.1145/2660193.2660201 Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Jeremy Yallop, David Sheets, and Anil Madhavapeddy. 2018. A modular foreign function interface. Science of Computer Programming, 164 (2018), 82–97.Google ScholarGoogle ScholarCross RefCross Ref
  55. Jyun-Yan You. 2021. Rust Bindgen. https://github.com/rust-lang/rust-bindgenGoogle ScholarGoogle Scholar

Index Terms

  1. Semantic soundness for language interoperability

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      PLDI 2022: Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation
      June 2022
      1038 pages
      ISBN:9781450392655
      DOI:10.1145/3519939
      • General Chair:
      • Ranjit Jhala,
      • Program Chair:
      • Işil Dillig

      Copyright © 2022 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 9 June 2022

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate406of2,067submissions,20%

      Upcoming Conference

      PLDI '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader